<!--#include file="../nav/admin_top.php" --> 
<script type="text/javascript">
var url_save = '<?=url::build('admin','users_add',array('reqtype'=>'json'))?>'; 
var url_return = '<?=url::build('admin','users')?>'; 
var rs_authgroup = {json_encode($rs_authgroup)};
$().ready(function(){  
	showLoading();  
  $('#username').focus();
}); 
/* 保存 */
function fnSave(){ 
	var form = serializeObj("#myform");



	/* 一些验证 */
	if($.trim(form.username) == '' || !fnRegExp('reg_username',form.username)){
		alert('请输入【登录名】');
		$('#username').focus();
		return false;
	}
	if($.trim(form.password) == '' || form['password'].length<4){
		alert('请输入【登录密码】(请输入4-16位的登录密码)');
		$('#password').focus();
		return false;
	}
	if(form.password2 != form.password){
		alert('两次密码需要输入相同密码');
		$('#password2').focus();
		return false;
	}
  
  $('button').attr('disabled','disabled');
	$.ajax({
		async:true,
		type:'post',
		url:url_save,
		data:{
			form:JSON.encode(form) 
		},
		success:function(e){
  		$('button').attr('disabled','');
			var ok = errorHandler(e);
			if(ok){　 
				jumpTo(url_return);
			}
		}
	});
}
</script>
<div class="titleDiv">
	<div class="titleCaption">
		<span class="captionSpan">后台用户管理 - 添加管理员</span>
		<span class="totalSpan"> <label id="captionNum"></label> </span>
	</div>
</div> 
<div  class="button_div">
		<button class="btn_save" onclick="fnSave()">保 存</button>
		<span class="gray">或</span> 
		<button class=" " onclick="jumpTo(url_return)">返 回</button>
</div> 
<form id="myform" action="" method="post" onsubmit="return false" >
<div class="blockdiv">
	<div class="titlediv">管理员基本信息</div>
	<table class="mytable" >
		<tr>
			<td class="mylabel"><span class="red">*</span>登录名：</td>
			<td class="myinfo" >
				<input type="text" class="textBox" id="username" name="username" maxlength="10" style="width:200px" />
				<span class="gray">请输入英文字母或数字</span>
			</td>  
		</tr> 
		<tr>
			<td class="mylabel"><span class="red">*</span>登录密码：</td>
			<td class="myinfo" >
				<input type="password" class="textBox" id="password" name="password" maxlength="16" style="width:200px" />
				<span class="gray">请输入4-16位的登录密码</span>
			</td>  
		</tr> 
		<tr>
			<td class="mylabel"><span class="red">*</span>确认密码：</td>
			<td class="myinfo" >
				<input type="password" class="textBox" id="password2" name="password2" maxlength="16" style="width:200px" />
			 
			</td>  
		</tr> 
		<tr>
			<td class="mylabel">显示姓名：</td>
			<td class="myinfo" >
				<input type="text" class="textBox" id="name" name="name" maxlength="10" style="width:200px" />
				<span class="gray"></span>
			</td>  
		</tr>
		<tr>
			<td class="mylabel">权限组：</td>
			<td class="myinfo" >
				<select class="textBox" id="authgroup_id" name="authgroup_id">
					<?PHP
					foreach($rs_authgroup as $v){
						echo '<option value="'.$v['id'].'" >'.$v['name'].'</option>';
					}
					?> 
				</select>
			</td>  
		</tr>
		<tr>
			<td class="mylabel">账户状态：</td>
			<td class="myinfo" >
				<select class="textBox" id="state" name="state">
					<option value="1" selected="selected">正常</option>
					<option value="2" >暂停使用</option>
				</select>
			</td>  
		</tr>
	</table> 
</div> 
  
</form>			
<div  class="button_div">
		<button class="btn_save" onclick="fnSave()">保 存</button>
		<span class="gray">或</span> 
		<button class=" " onclick="jumpTo(url_return)">返 回</button>
</div>  
<!--#include file="../nav/admin_bottom.php" -->